package com.jz.netthings.application.bodyCheck.controller;


import com.jz.netthings.application.bodyCheck.bean.BodyCheck;
import com.jz.netthings.application.bodyCheck.service.BodyCheckService;
import com.jz.netthings.exception.AdscmSystemException;
import com.jz.netthings.support.SimpleCoreResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.text.SimpleDateFormat;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author lzf
 * @since 2019-02-26
 */
@RestController
@RequestMapping("adscm/application/bodyCheck")
public class BodyCheckController {

    @Autowired
    BodyCheckService bodyCheckService;
    SimpleDateFormat df=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");


    @RequestMapping("/queryByTime")
    public SimpleCoreResponse queryByTime(String recodeTime,String bigCreateTime,String lessCreateTime,String cardid,String name,Integer pageSize,Integer currentPage) throws AdscmSystemException{
        return new SimpleCoreResponse("200","查询成功",bodyCheckService.queryByTime(recodeTime,bigCreateTime,lessCreateTime,cardid,name,pageSize,currentPage));
    }


    @RequestMapping("/queryDoctor")
    public SimpleCoreResponse queryDoctor(String id){
        return new SimpleCoreResponse("200","查询成功",bodyCheckService.queryDoctor(id));
    }

    @RequestMapping("/update")
    public SimpleCoreResponse update(@RequestBody BodyCheck bodyCheck, HttpServletRequest request) throws AdscmSystemException, IOException {
//        String tokenId=request.getParameter("tokenId");
//        Token token= AdscmBaseUtils.getInstance().getTokenByTokenId(tokenId,tokenRedisTemplate);
//        bodyCheck.setCreateNurse(String.valueOf(token.getUser().getId()));
//        bodyCheck.setRecodeCreateTime(df.format(new Date()));
        return new SimpleCoreResponse("200","修改成功",bodyCheckService.updateByBodyCheckNo(bodyCheck));
    }

    @RequestMapping("/bodyCheckStatus")
    public SimpleCoreResponse bodyCheckStatus(String type){
        return new SimpleCoreResponse("200","查询状态成功",bodyCheckService.bodyCheckStatus(type));

    }

    @RequestMapping("/bodyCheckInfo")
    public SimpleCoreResponse bodyCheckInfo(String cardid) throws AdscmSystemException{
        return new SimpleCoreResponse("200","查询浆员基本信息成功",bodyCheckService.BODY_CHECK_INFOS(cardid));
    }

    @RequestMapping("/queryByName")
    public SimpleCoreResponse queryByName(String name,String bigCreateTime,String lessCreateTime){
        return new SimpleCoreResponse("200","根据名字查询基本信息成功",bodyCheckService.queryByName(name,bigCreateTime,lessCreateTime));
    }
}

